﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace JustPlus
{
    /// <summary>
    /// DefCheckBox.xaml 的交互逻辑
    /// </summary>
    public partial class DefCheckBox : UserControl
    {
        public bool OriChecked = true;
        public bool isChecked;
        public DefCheckBox()
        {
            InitializeComponent();
            isChecked = OriChecked;
            this.Loaded += new RoutedEventHandler(UpdateCheckBox);
        }

        public void UpdateCheckBox(object sender, RoutedEventArgs e)
        {
            if (OriChecked == false)
                label3.Margin = new Thickness(0,0,0,0);
        }

        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (OriChecked == true)
            {
                if (isChecked == true)
                {
                    isChecked = false;
                    Storyboard sb = (Storyboard)Resources["On_On2Off"];
                    sb.Begin();
                }
                else if (isChecked == false)
                {
                    isChecked = true;
                    Storyboard sb = (Storyboard)Resources["On_Off2On"];
                    sb.Begin();
                }
            }
            else if (OriChecked == false)
            {
                if (isChecked == true)
                {
                    isChecked = false;
                    Storyboard sb = (Storyboard)Resources["Off_On2Off"];
                    sb.Begin();
                }
                else if (isChecked == false)
                {
                    isChecked = true;
                    Storyboard sb = (Storyboard)Resources["Off_Off2On"];
                    sb.Begin();
                }
            }
            
        }
    }
}
